package com.spsoft.system.controller;

import com.spsoft.core.annotation.AnonymousAccess;
import com.spsoft.core.annotation.Log;
import com.spsoft.core.controller.BaseController;
import com.spsoft.core.enums.LogActionType;
import com.spsoft.core.enums.LogMenuEnum;
import com.spsoft.core.model.Result;
import com.spsoft.system.model.vo.FramedepartmentListVO;
import com.spsoft.system.model.vo.OrganVo;
import com.spsoft.system.service.FramedepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wangy
 * @date 2023/12/13 18:27
 */
@Api(tags = {"部门信息查询"})
@Validated
@Slf4j
@RestController
@RequestMapping("/framedepartment")
@RequiredArgsConstructor
public class FramedepartmentController extends BaseController {

    private final FramedepartmentService framedepartmentService;

    @ApiOperation("部门信息-下拉框部门列表")
    @AnonymousAccess(value = "/getFramedepartmentList", method = RequestMethod.GET, permissionCode = "")
    @Log(value = "部门信息-下拉框部门列表", type = LogActionType.SELECT, menuName = LogMenuEnum.SYSTEM_BASIC_INFO)
    public Result<List<FramedepartmentListVO>> getDefBIzdictByLxdm() {
        return framedepartmentService.getDeptList();
    }

    @ApiOperation("部门信息树状json-下拉框部门列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isAll", value = "是否全部(true表示全部，false表示当前机构及下级", dataTypeClass = boolean.class, dataType = "boolean", paramType = "query", required = true)
    })
    @AnonymousAccess(value = "/getTreeFramedepartmentList", method = RequestMethod.POST, permissionCode = "")
    @Log(value = "部门信息树状json-下拉框部门列表", type = LogActionType.SELECT, menuName = LogMenuEnum.SYSTEM_BASIC_INFO)
    public Result<OrganVo> getTreeFramedepartmentList(@RequestParam("isAll") boolean isAll) {
        return framedepartmentService.getDeptList(isAll);
    }

}
